dnl matlabarch.m4 --- check for Matlab machine architecture.
dnl
dnl This program is in the public domain.

# AX_MATLAB_ARCH
# --------------
# Check for Matlab machine architecture.
AC_DEFUN([AX_MATLAB_ARCH],
[dnl
AC_PREREQ([2.50])
AC_CACHE_CHECK([for Matlab machine architecture], [ax_cv_matlab_arch],
[if test "${MATLAB_ARCH+set}" = set ; then
    ax_cv_matlab_arch="$MATLAB_ARCH"
else
    AC_CANONICAL_HOST
    case ${host_os} in

        solaris* | sunos*)
            case ${host_cpu} in
                sparc)
                    ax_cv_matlab_arch=sol64
                    ;;
                i*86)
                    ax_cv_matlab_arch=sola64
                    ;;
            esac
            ;;
        
        linux | linux-gnu)
            case ${host_cpu} in
                i*86)
                    ax_cv_matlab_arch=glnx86
                    ;;
                ia64)
                    ax_cv_matlab_arch=glnxi64
                    ;;
                x86_64)
                    ax_cv_matlab_arch=glnxa64
                    ;;
            esac
            ;;
      
        darwin*)
            case ${host_cpu} in
                powerpc)
                    ax_cv_matlab_arch=mac
                    ;;
                i*86)
                    if [ test "`/usr/sbin/sysctl -n hw.cpu64bit_capable`" = "0" ]; then
                        ax_cv_matlab_arch=maci
                    fi
                    if [ test -d "$MATLAB/bin/maci64" ]; then
                        ax_cv_matlab_arch=maci64
                    else
                        ax_cv_matlab_arch=maci
                    fi
                    ;;
                x86_64)
                    ax_cv_matlab_arch=maci64
                    ;;
            esac
            ;;
        
        cygwin* | mingw*)
            case ${host_cpu} in
                i*86)
                    ax_cv_matlab_arch=w32
                    ;;
                x86_64)
                    ax_cv_matlab_arch=w64
                    ;;
            esac
            ;;

        *)
            ax_cv_matlab_arch=unknown
            ;;
    esac
fi])
MATLAB_ARCH="$ax_cv_matlab_arch"
AC_SUBST([MATLAB_ARCH])
])

dnl matlabarch.m4 ends here
